//
//  MemberListCell.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/10.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "MemberListCell.h"

@interface MemberListCell()

@property(nonatomic,strong)UILabel *address;
@property(nonatomic,strong)UILabel *address1;
@property(nonatomic,strong)UILabel *userName;
@property(nonatomic,strong)UILabel *integral;
@property(nonatomic,strong)UILabel *integral1;
@property(nonatomic,strong)UILabel *grade;
@property(nonatomic,strong)UILabel *grade1;
@property(nonatomic,strong)UILabel *createDate;
@property(nonatomic,strong)UILabel *createDate1;
@property(nonatomic,strong)UIImageView*seximage;
@property(nonatomic,strong)UIImageView*headerImage;
@property(nonatomic,strong)UILabel *lineLabel;
@end
@implementation MemberListCell

- (void)awakeFromNib {
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createView];
        [self setViewAutoLayout];
    }
    
    return self;
    
}
-(void)createView
{
    
    
    self.headerImage=[[UIImageView alloc] init];
    [self.headerImage.layer setCornerRadius:4.0];
    [self.headerImage.layer setBorderWidth:0.3];
    [self.headerImage.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
    [self.headerImage.layer setBorderColor:colorref2];
    [self.headerImage setImageWithURL:[NSURL URLWithString:@""]placeholderImage:[UIImage imageNamed:@""]];
   [self addSubview:self.headerImage];
    
    
    self.userName=[[UILabel alloc] init];
    self.userName.font= [UIFont systemFontOfSize:17];
    self.userName.textColor=[UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1.0];
    [self addSubview:self.userName];
    self.seximage=[[UIImageView alloc] init];
    [self addSubview:self.seximage];
    self.integral=[[UILabel alloc] init];
    self.integral.font= [UIFont systemFontOfSize:14];
    self.integral.text=@"积分";
    self.integral.textColor=zhonghuiColor;
    [self addSubview:self.integral];
    self.integral1=[[UILabel alloc] init];
    self.integral1.font= [UIFont systemFontOfSize:14];
    self.integral1.textColor=shenhuiColor;
    [self addSubview:self.integral1];
    self.grade=[[UILabel alloc] init];
    self.grade.font= [UIFont systemFontOfSize:14];
    self.grade.text=@"等级";
    self.grade.textColor=zhonghuiColor;
    [self addSubview:self.grade];
    self.grade1=[[UILabel alloc] init];
    self.grade1.font= [UIFont systemFontOfSize:14];
    self.grade1.textColor=[UIColor whiteColor];
    [self addSubview:self.grade1];
    self.lineLabel=[[UILabel alloc] init];
    [self.lineLabel setBackgroundColor:[UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
    self.lineLabel.textColor=[UIColor clearColor];
    [self addSubview:self.lineLabel];
    
}
-(void)setModel:(MemberListModel *)model
{
    NSArray *buttonContent = @[@"帅哥哈",@"美女哈"];
    for (int i = 0;  i<2; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(75+80*i,50, 60, 15);
        [button setTitle:[buttonContent objectAtIndex:i] forState:UIControlStateNormal];
        button.titleLabel.font=[UIFont systemFontOfSize:11];
        CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
        CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){209/255.0,170/255.0, 56/255.0, 1.0   });
        button.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:234/255.0 alpha:1];
        [button.layer setBorderColor:colorref2];//边框颜色
        [button.layer setBorderWidth:0.5];
        [button.layer setCornerRadius:10];
        [button setTitleColor:[UIColor colorWithRed:209/255.0 green:170/255.0 blue:56/255.0 alpha:1.0] forState:0];
        button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentCenter;
        [self addSubview:button];
    }

    
//  [self.headerImage setImageWithURL:[NSURL URLWithString:model.]placeholderImage:[UIImage imageNamed:@""]];
   self.integral1.text=[NSString stringWithFormat:@"%@",  model.integral];
    self.userName.text=[NSString stringWithFormat:@"%@",  model.userName];
    self.lineLabel.text=[NSString stringWithFormat:@"%@",model.userName];
    if (![model.sex  isEqual:[NSNull null]]) {
    if ([model.sex isEqualToString:@"男"]) {
            self.seximage.image=[UIImage imageNamed:@"nan"];
        }else{
            self.seximage.image=[UIImage imageNamed:@"nv"];
        }
    }else{
        self.seximage.image=[UIImage imageNamed:@"nv"];}
    if ([[NSString stringWithFormat:@"%@", model.grade ] isEqualToString:@"1"]) {
        self.grade1.text=@"金";
        self.grade1.backgroundColor=[UIColor colorWithRed:209/255.0 green:170/255.0 blue:56/255.0 alpha:1.0];
    }
    if ([[NSString stringWithFormat:@"%@", model.grade] isEqualToString:@"2"]) {
        self.grade1.text=@"银";
        self.grade1.backgroundColor=[UIColor colorWithRed:175/255.0 green:175/255.0 blue:175/255.0 alpha:1.0];
    }
    if ([[NSString stringWithFormat:@"%@", model.grade] isEqualToString:@"3"]) {
        self.grade1.text=@"铜";
        self.grade1.backgroundColor=[UIColor colorWithRed:126/255.0 green:56/255.0 blue:39/255.0 alpha:1.0];
    }
    
    


}
-(void)setViewAutoLayout
{
    
  [self.headerImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@50);
        make.width.equalTo(@50);
        make.top.equalTo(self.mas_top).with.offset(20);
    }];
   [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerImage.mas_right).with.offset(10);
        make.height.equalTo(@16);
        make.top.equalTo(self.mas_top).with.offset(25);
    }];
    
    [self.seximage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.userName.mas_right).with.offset(3);
            make.width.equalTo(@20);
    
            make.height.equalTo(@20);
    
            make.top.equalTo(self.mas_top).with.offset(25);
        }];
    [self.grade mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.seximage.mas_right).with.offset(15);
        
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.seximage.mas_centerY) ;
    }];
    
    [self.grade1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.grade.mas_right).with.offset(3);
        make.height.equalTo(@15);
        make.width.equalTo(@15);
        make.centerY.equalTo(self.seximage.mas_centerY) ;
        
    }];
        [self.integral mas_makeConstraints:^(MASConstraintMaker *make) {
        
            make.left.equalTo(self.grade1.mas_right).with.offset(15);
    
            make.height.equalTo(@14);
    
            make.centerY.equalTo(self.seximage.mas_centerY) ;
        }];

    [self.integral1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.integral.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.seximage.mas_centerY) ;

    }];
    


    
    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(10);
        make.right.equalTo(self.mas_right).with.offset(-10) ;
        
        make.height.equalTo(@1);
        
        make.top.equalTo(@108).with.offset(0);
    }];
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
